;
; sprite scroll text source code module
;

; sprites 184 , 185 @ vic bnk - memory 
; 6e00-6e7f

sscrollirq
	inc $d019
	
	lda #126	; Y expand
        sta $d017
	
	inc scsinuspos
	ldx scsinuspos
	lda scsinus,x
	sta $d002
	lda #30
	sta $d003

	lda #<irq
	ldy #>irq
	sta $0314
	sty $0315

	lda #$40
	sta $D012
	lda $d011
	and #127
	sta $d011

;	lda #74
;	sta $d004
;	lda #20
;	sta $d005
	
;	lda #1
;	sta $d02e
;	sta $d02f
	
	lda #184
	sta $6c00-7
;	lda #185
;	sta $6c00-6



;	lda #255
;	sta $d015

	; 13 * 64 = 832

;	jsr scrollsetup
	
	jsr irqss
	
	jmp $ea81


vpos	.byte 7
kolum 	.byte 0


irqss	
	;inc $d020

;	lda #255
;	sta 896

j2
	clc
	ldx kolum
	lda xtab,x
	tax
	
	asl $6e40,x	;2nd sprite
	rol $6e00+2,x   ;1st sprite
	rol $6e00+1,x
	rol $6e00,x
	
	inc kolum
	lda kolum
	cmp #8
	bne j2

	lda #0
	sta kolum
	
	dec vpos
	bne j3
	lda #7
	sta vpos
	jsr bierznak
j3

	;dec $d020
	rts	

xtab 
.byte 0,3,6,9,12,15,18,21,24,27

scrollsetup	 
	lda #<stext
	ldx #>stext
	sta $b4
	stx $b5
	rts

bierznak

	
	inc $b4
	bne jz
	inc $b5
jz
	ldy #$00
	lda ($b4),y
	bne walwekran
	jsr scrollsetup
	jmp dalejs

walwekran 
	; b6 , b7
	
	;sta $fe
	
	LDY #0
	STY $9f
	
	asl a
	rol $9f
	asl a
	rol $9f
	asl a
	rol $9f
	sta $9e
	
	clc
	lda $9f
	adc #$3e
	sta $9f
	
; ten adres jest wyliczany ok - kod dotad 100% ok	
;	jmp *
	
	ldy #7
	
jx	lda ($9e),y
	sta xregtemp

	sty yregtemp
	lda xtab,y
	tay
	lda xregtemp
	sta $6e40,y
	
	ldy yregtemp

	dey
	bpl jx
	

dalejs	rts

xregtemp .byte 0	
yregtemp .byte 0	
	
stext 
.scru " welcome to 69 postions." 
.scru "if you use 1541 then you will be icon-prompted for flipping disk side (only once). "
.scru " use joy in port 2 or keyboard: crsr keys-select tune, f1-play , f3-stop , f5-pause , "
.scru "return or f7-load+play. use left arrow to toggle manual box and jukebox mode. "

.scru "press 1 2 or 3 to set one , two or three minutes of playtime for jukebox mode. in jukebox mode "
.scru "screen is turned off when tune switches - for faster loading and unpacking. c= + q resets C64. "

.scru "                                www.vulture.c64.org                                    "
.byte $00	
	
	;;;;;;;;

scsinuspos .byte 0
	
scsinus
.byte $C1,$C5,$CA,$CE,$D2,$D5
      .byte $D9,$DC,$E0,$E3,$E6,$E8
      .byte $EB,$ED,$EF,$F1,$F3,$F4
      .byte $F6,$F7,$F8,$F9,$FA,$FB
      .byte $FC,$FD,$FD,$FD,$FE,$FE
      .byte $FE,$FF,$FF,$FF,$FF,$FF
      .byte $FF,$FF,$FF,$FF,$FF,$FF
      .byte $FF,$FF,$FF,$FF,$FF,$FF
      .byte $FF,$FF,$FF,$FF,$FF,$FF
      .byte $FE,$FE,$FE,$FE,$FD,$FD
      .byte $FC,$FB,$FB,$FA,$F9,$F7
      .byte $F6,$F5,$F3,$F1,$EF,$ED
      .byte $EB,$E8,$E6,$E3,$E0,$DD
      .byte $D9,$D6,$D2,$CE,$CA,$C6
      .byte $C1,$BD,$B8,$B3,$AE,$A9
      .byte $A4,$9F,$9A,$94,$8F,$89
      .byte $84,$7F,$79,$74,$6F,$6A
      .byte $65,$60,$5B,$57,$52,$4E
      .byte $4A,$47,$43,$40,$3D,$3B
      .byte $38,$36,$35,$34,$33,$32
      .byte $32,$32,$33,$34,$35,$37
      .byte $39,$3B,$3E,$41,$45,$49
      .byte $4D,$51,$56,$5B,$60,$65
      .byte $6B,$71,$77,$7D,$83,$8A
      .byte $90,$96,$9D,$A3,$AA,$B0
      .byte $B6,$BC,$C2,$C8,$CE,$D3
      .byte $D9,$DE,$E2,$E7,$EB,$EE
      .byte $F2,$F5,$F7,$FA,$FC,$FD
      .byte $FE,$FF,$FF,$FF,$FE,$FD
      .byte $FC,$FA,$F8,$F5,$F2,$EF
      .byte $EB,$E7,$E3,$DE,$D9,$D4
      .byte $CF,$C9,$C3,$BD,$B7,$B1
      .byte $AA,$A4,$9E,$97,$91,$8A
      .byte $84,$7E,$78,$72,$6C,$66
      .byte $61,$5B,$56,$52,$4D,$49
      .byte $45,$42,$3E,$3C,$39,$37
      .byte $35,$34,$33,$32,$32,$32
      .byte $33,$33,$35,$36,$38,$3A
      .byte $3D,$40,$43,$46,$4A,$4E
      .byte $52,$56,$5B,$5F,$64,$69
      .byte $6E,$74,$79,$7E,$84,$89
      .byte $8E,$94,$99,$9E,$A4,$A9
      .byte $AE,$B3,$B8,$BC

